home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-15 | 5.3 KB | 160 lines | [TEXT/Moml] |
- (* test/filesys.sml
- PS 1995-03-23
- *)
-
- (* Mac: changed "/" to ":", "." to ":", ".." to "::"
- 10a is testing that remove doesn't work on directories
- -- it does on the Mac; this is probably OK
- testcycl -> testcycl can this be done on the Mac?
- readDir doen't make "." and ".." -- commented out
- so rewindDir test is less worthwhile (but it does work!)
- test13a & 13c fail because readLink fails for non-links
- test13b fails because readLink makes full pathname
- *)
-
- (* DOS: Plain WRONG: test6a, test9a (and test9b);
- Excusable: test8b, test11b, test12a, test13a, test13b, test13c
- *)
-
- (* This requires two links to be present in the current directory:
- testlink -> README
- testcycl -> testcycl
- testbadl -> exists.not
- Moreover, the file README must exist and the file exists.not not.
- *)
-
-
- use "auxil.sml";
-
- local
- open FileSys
- (* Clean up: *)
- val _ = (rmDir "testdir") handle OS.SysErr _ => ();
- val _ = (rmDir "testdir2") handle OS.SysErr _ => ();
- in
-
- val test1a = (mkDir "testdir" seq "OK") handle _ => "WRONG";
- val test1b = (mkDir "testdir" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
-
- val test2 = check'(fn _ => isDir "testdir");
-
- val test3 = check'(fn _ => access("testdir", [A_READ, A_EXEC, A_WRITE]));
-
- local
- val cdir = getDir();
- in
- val test4a = (chDir cdir seq "OK") handle _ => "WRONG";
- val test4b = check'(fn _ => cdir = getDir());
- val _ = chDir "testdir";
- val test4c = check'(fn _ => cdir <> getDir());
- val _ = chDir "::";
- val test4d = check'(fn _ => cdir = getDir());
- end;
-
- val _ = rename{old = "testdir", new = "exists.not"};
-
- val test5 = (rmDir "exists.not" seq "OK") handle _ => "WRONG";
-
- val test6a = (openDir "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6b = (isDir "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6c = (rmDir "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6d = (chDir "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6e = (realPath "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6f = (modTime "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6g = (setTime("exists.not", NONE) seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6h = (remove "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6i = (rename{old="exists.not", new="testdir2"} seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test6j = check'(fn _ => not (access("exists.not", [])));
-
- val _ = mkDir "testdir";
-
- local
- val dstr = openDir "testdir";
- in
- val test7a =
- check'(fn _ => (* ":" = readDir dstr
- andalso "::" = readDir dstr
- andalso *) "" = readDir dstr);
- val _ = rewindDir dstr;
- val test7b =
- check'(fn _ => (* ":" = readDir dstr
- andalso "::" = readDir dstr
- andalso *) "" = readDir dstr);
- val _ = closeDir dstr;
- val test7c = (readDir dstr seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test7d = (rewindDir dstr seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test7e = (closeDir dstr seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- end
-
- val test8a =
- check'(fn _ => realPath ":" = getDir ());
- val test8b =
- check'(fn _ => realPath "testlink" = getDir() ^ ":README");
- val test8c = (realPath "testcycl" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test8d = (realPath "testbadl" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
-
- val test9a =
- check'(fn _ =>
- setTime ("README", SOME (Time.realToTime 1E6)) = ());
- val test9b =
- check'(fn _ => modTime "README" = Time.realToTime 1E6);
-
- (* -- e
- val test10a = (remove "testdir" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- *)
- val test10a = "WRONG, because remove removes directories.";
- val test10b =
- check'(fn _ =>
- rename{old = "testdir", new = "testdir2"} = ());
- val test10c =
- check'(fn _ => isDir "testdir2");
-
- val test11a =
- check'(fn _ => not (access ("testdir", [])));
- val test11b =
- check'(fn _ => access("testlink", []));
- val test11c =
- check'(fn _ => not (access("testbadl", [])));
-
- val test12a =
- check'(fn _ => (* isLink "testcycl"
- andalso *) isLink "testlink"
- andalso isLink "testbadl");
- val test12b =
- check'(fn _ => not (isLink "testdir2"
- orelse isLink "README"));
- val test12c = (isLink "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
-
- val test13a =
- check'(fn _ => readLink "testcycl" = "testcycl");
- val test13b =
- check'(fn _ => readLink "testlink" = "README");
- val test13c =
- check'(fn _ => readLink "testbadl" = "exists.not");
- val test13d = (readLink "testdir2" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
- val test13e = (readLink "exists.not" seq "WRONG")
- handle OS.SysErr _ => "OK" | _ => "WRONG";
-
- val test14 = (tmpName{dir=NONE, prefix=NONE} seq "OK");
-
- val _ = rmDir "testdir2";
- end
-